//
//  CustomCollectionCell.m
//  22--HomeWork QQ音乐界面
//
//  Created by 冀永金 on 16/8/15.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "CustomCollectionCell.h"
#import "UIImageView+WebCache.h"
#import "LastModel1.h"
#import "MVListModel.h"
@interface CustomCollectionCell ()
@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *singerLabel;
@property (nonatomic, strong) UILabel *descLabel;
@end
@implementation CustomCollectionCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self config];
    }
    return self;
}
- (void)config {
    self.image = [[UIImageView alloc]init];
    [self.contentView addSubview:_image];
    //_image.backgroundColor = [UIColor yellowColor];
    self.titleLabel = [[UILabel alloc]init];
    [self.contentView addSubview:_titleLabel];
    //_titleLabel.backgroundColor = [UIColor redColor];
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.image.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height * 2 / 3);
    _titleLabel.frame = CGRectMake(0, self.bounds.size.height * 2 /  3+ 2, self.bounds.size.width, 35);
}
- (void)setLastModel:(LastModel1 *)lastModel {
    _lastModel = lastModel;
    self.titleLabel.text = [lastModel.mvtitle stringByAppendingString:[NSString stringWithFormat:@"--%@",lastModel.singername]];
    if (lastModel.picurl.length != 0) {
        [self.image sd_setImageWithURL:[NSURL URLWithString:lastModel.picurl] placeholderImage:[UIImage imageNamed:@"6"]];
        
    }
    else {
        NSString *urlStr = [NSString stringWithFormat:@"http://shp.qpic.cn/qqvideo_ori/0/%@_360_204/0?max_age=259200", lastModel.vid];
        [self.image sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"6"]];
    }
}

@end
